﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PlanningGIS.Win.Controls
{
    /// <summary>
    /// 控件对象扩展
    /// </summary>
    public static class ControlExtension
    {

        /// <summary>
        /// 获取控件对象所在的窗体，若不存在，在返回null
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        public static Form GetParentForm(this Control control)
        {
            if (control == null || control.Parent == null) return null;
            if (control.Parent is Form) return control.Parent as Form;
            else return GetParentForm(control.Parent);
        }
    }
}
